Imports Microsoft.VisualBasic
Imports System.Data.SqlClient
Imports System.Data

Public Class clsConsultasComunes
    Public Function objCargarConstante(ByVal ConCodigo As Integer, ByVal NumCaracteres As Integer, _
                                        ByVal ConLeft As Integer, ByVal ConValLeft As Integer, _
                                        Optional ByVal ConRight As Integer = 0, Optional ByVal ConValRight As Integer = 0, _
                                        Optional ByVal SinVal As Integer = 0, _
                                        Optional ByVal conValorIn As String = "", _
    Optional ByVal MyTrans As SqlTransaction = Nothing, Optional ByVal Cn As SqlConnection = Nothing) As SqlDataReader

        Dim Sql As String = String.Empty
        Dim Sql2 As String = String.Empty

        If Not conValorIn Is String.Empty Then
            conValorIn = " AND nConValor In(" & conValorIn & ")"
        End If

        If SinVal <> 0 Then
            Sql2 = "And (nConValor<>" & SinVal & ")"
        End If

        If ConRight = 0 Then
            Sql = "SELECT nConCodigo, nConValor, cConDescripcion " & _
             "FROM Constante WHERE (nConCodigo = " & ConCodigo & ") AND " & _
             "(LEN(nConValor) = " & NumCaracteres & ") AND " & _
             "(LEFT(nConValor, " & ConLeft & ") = " & ConValLeft & ") " & Sql2 & conValorIn
        Else
            Sql = "SELECT nConCodigo, nConValor, cConDescripcion " & _
             "FROM Constante WHERE (nConCodigo = " & ConCodigo & ") AND " & _
             "(LEN(nConValor) = " & NumCaracteres & ") AND " & _
             "(LEFT(nConValor, " & ConLeft & ") = " & ConValLeft & ") AND (RIGHT(nConValor, " & ConRight & ") = " & ConValRight & ")" & Sql2 & conValorIn
        End If

        Dim MiClase As New clsManejadorDatos
        Return MiClase.objExecuteReader(Sql, MyTrans, Cn)
        MiClase = Nothing
    End Function
    Public Function objInterface(ByVal MyTrans As SqlTransaction, ByVal Cn As SqlConnection, _
                    Optional ByVal CantDesLeft As Integer = 0, Optional ByVal CantDesRigth As Integer = 0, _
                    Optional ByVal LeftDescripcion As String = "", _
                    Optional ByVal RigthDescripcion As String = "", Optional ByVal LikeDescripcion As String = "", _
                    Optional ByVal nIntClase As Integer = 0, Optional ByVal nIntTipo As Integer = 0, _
                    Optional ByVal ByCodigo As Integer = 0, Optional ByVal ByLenTotJerarquia As Integer = 0, _
                    Optional ByVal ByLeftJerarquia As Integer = 0, Optional ByVal DesJerarquia As String = "", _
                    Optional ByVal OrdenaDescripcion As Integer = 0) As SqlDataReader


        Dim SQL As String = "Select * from Interface Where nIntClase = " & nIntClase & " AND nIntTipo = " & nIntTipo & ""

        If CantDesLeft > 0 Then SQL += " AND Left(cIntDescripcion, " & CantDesLeft & ") = '%" & LeftDescripcion & "%' "

        If CantDesRigth > 0 Then SQL += " AND Rigth(cIntDescripcion, " & CantDesRigth & ") = '%" & RigthDescripcion & "%' "

        If LikeDescripcion <> String.Empty Then SQL += " AND cIntDescripcion Like '%" & LikeDescripcion & "%' "

        If ByCodigo > 0 Then SQL += " AND nIntCodigo = " & ByCodigo & ""

        If ByLenTotJerarquia > 0 Then SQL += " AND len(cIntJerarquia) = " & ByLenTotJerarquia & ""

        If ByLeftJerarquia > 0 Then SQL += " AND Left(cIntJerarquia, " & ByLeftJerarquia & ") = '" & DesJerarquia & "'"

        If OrdenaDescripcion = 1 Then SQL += " ORDER BY cIntDescripcion"

        Dim MiClase As New clsManejadorDatos
        Return MiClase.objExecuteReader(SQL, MyTrans, Cn)
        MiClase = Nothing

    End Function
    Public Function ObjPeriodoActual(ByVal TipPeriodo As Integer, ByVal MyTrans As SqlTransaction, _
                    ByVal Cn As SqlConnection) As SqlDataReader

        Dim SQL As String = "Select nPrdCodigo, cPrdDescripcion From Periodo Where nPrdActividad = " & TipPeriodo & " " & _
                            "AND nprdEstado=1 AND (Select getdate()) between dPrdIni AND dPrdFin"

        Dim MiClase As New clsManejadorDatos
        Return MiClase.objExecuteReader(SQL, MyTrans, Cn)
        MiClase = Nothing
    End Function
    Public Function Get_Constante(ByVal ConCodigo As Integer, ByVal MyTrans As SqlTransaction, ByVal Cn As SqlConnection, _
                    Optional ByVal ConValNot As String = "") As SqlDataReader

        Dim SQL As String = String.Empty
        If ConValNot = String.Empty Then
            SQL = "Select * from Constante Where nConCodigo = " & ConCodigo & " " & _
                                "Order By nConValor"
        Else
            SQL = "select * from Constante Where nConCodigo = " & ConCodigo & " AND nConValor not in(" & ConValNot & ")" & _
                "Order By nConValor"
        End If

        Dim MiClase As New clsManejadorDatos
        Return MiClase.objExecuteReader(SQL, MyTrans, Cn)
        MiClase = Nothing
    End Function
    Public Function Get_Periodo_By_Permisos(ByVal TipPeriodo As Integer, ByVal PerCodigo As String, _
                    ByVal MyTrans As SqlTransaction, ByVal Cn As SqlConnection) As SqlDataReader

        Dim SQL As String = "SELECT SPG.cBieCodigo, P.cPrdDescripcion, P.nPrdCodigo  FROM SPerGruObu SPG INNER JOIN  Periodo P ON " & _
                            "SPG.cBieCodigo = P.nPrdCodigo  WHERE (SPG.cPerCodigo = '" & PerCodigo & "')  AND (SPG.nSGruCodigo = 123) " & _
                            "AND (P.nPrdActividad=" & TipPeriodo & ") ORDER BY P.cPrdDescripcion"

        Dim MiClase As New clsManejadorDatos
        Return MiClase.objExecuteReader(SQL, MyTrans, Cn)
        MiClase = Nothing
    End Function
    Public Function Get_Periodo_By_Tipo_AND_Permisos(ByVal TipPeriodo As Integer, ByVal PerCodigo As String, _
                    ByVal MyTrans As SqlTransaction, ByVal Cn As SqlConnection) As SqlDataReader

        Dim SQL As String = "select distinct p.nPrdCodigo,cPrdDescripcion + '-' + convert(char(2),p.nPrdactividad) as cPrdDescripcion " & _
                            "from (select distinct nCurGruCodigo from Curgrupo) S " & _
                            "inner join CurGrupo cg on s.nCurGruCodigo=cg.nCurGruCodigo " & _
                            "inner join periodo p on cg.nprdCodigo=p.nPrdCodigo " & _
                            "inner join (select nObjCodigo from perusugruacc where cpercodigo= '" & PerCodigo & "' and nSisGruTipo=1004 " & _
                            "and nObjTipo=1007) Ps on p.nPrdCodigo=ps.nObjCodigo " & _
                            "Where p.nPrdactividad = " & TipPeriodo & ""

        Dim MiClase As New clsManejadorDatos
        Return MiClase.objExecuteReader(SQL, MyTrans, Cn)
        MiClase = Nothing
    End Function
    Public Function Get_Periodo_By_Permisos_Generico(ByVal nPrdActividad As Integer, ByVal cPerCodigo As String, _
                    ByVal MyTrans As SqlTransaction, ByVal Cn As SqlConnection) As SqlDataReader

        Dim SQL As String = "Select Distinct P.nPrdCodigo, P.cPrdDescripcion From PerUsuGruAcc PUGA " & _
                            "Inner Join Periodo P ON P.nPrdCodigo = PUGA.nObjCodigo " & _
                            "Where P.nPrdActividad = " & nPrdActividad & " AND PUGA.cPerCodigo = '" & cPerCodigo & "'"

        Dim MiClase As New clsManejadorDatos
        Return MiClase.objExecuteReader(SQL, MyTrans, Cn)
        MiClase = Nothing
    End Function
    Public Function Get_Academico_Curricula(ByVal EscCodigo As Integer, ByVal MyTrans As SqlTransaction, ByVal Cn As SqlConnection) As SqlDataReader

        Dim SQL As String = "SELECT DISTINCT Cur.nUniOrgCodigo, PE.nCurCodigo, Cur.cCurDescripcion, PE.nCicCodigo, " & _
                            "ISNULL(CurDen.cCurDenNombre, Cic.cConDescripcion) AS Ciclo , PE.nAsiCodigo, PE.nAsiCodigoE, " & _
                            "A.cAsiDescripcion, PE.nMenCodigo, Men.cConDescripcion AS Mension, " & _
                            "PE.cCurDetCod, PE.nCurDetCredito, PE.nCurDetHorTeorica, PE.nCurDetHorPractica , " & _
                            "PE.nCurDetTipo, Estado.cConDescripcion as Estado FROM (SELECT CD.nCurCodigo, " & _
                            "CD.nCicCodigo, CD.nAsiCodigo, ISNULL(CurDetEspecial.nMenCodigo, 0) AS nMenCodigo, " & _
                            "ISNULL(CurDetEspecial.cCurDetCod, CD.cCurDetCod) AS cCurDetCod, " & _
                            "ISNULL(CurDetEspecial.nAsiCodigoE, CD.nAsiCodigo) AS nAsiCodigoE, CD.nCurDetCredito, " & _
                            "CD.nCurDetHorTeorica, CD.nCurDetHorPractica, CD.nCurDetTipo FROM CurDetalle " & _
                            "CD LEFT OUTER JOIN CurDetEspecial ON CD.nCurCodigo = CurDetEspecial.nCurCodigo " & _
                            "AND CD.nCicCodigo = CurDetEspecial.nCicCodigo AND CD.nAsiCodigo = CurDetEspecial.nAsiCodigo) PE " & _
                            "INNER JOIN Asignatura A ON PE.nAsiCodigoE = A.nAsiCodigo INNER JOIN " & _
                            "Curriculo Cur ON PE.nCurCodigo = Cur.nCurCodigo INNER JOIN " & _
                            "(SELECT nConValor, cConDescripcion FROM Constante C WHERE nConCodigo = 1050) Cic " & _
                            "ON PE.nCicCodigo = Cic.nConValor LEFT OUTER JOIN (SELECT nConValor, " & _
                            "cConDescripcion FROM Constante C WHERE nConCodigo = 1044) Estado ON Cur.nCurActual = Estado.nConValor " & _
                            "LEFT OUTER JOIN CurDenominacion CurDen ON PE.nCurCodigo = " & _
                            "CurDen.nCurCodigo AND PE.nCicCodigo = CurDen.nCicCodigo LEFT OUTER JOIN " & _
                            "(SELECT nConValor, cConDescripcion FROM Constante C WHERE nConCodigo = 1122) Men ON " & _
                            "PE.nMenCodigo = Men.nConValor WHERE Cur.nUniOrgCodigo = " & EscCodigo & " " & _
                            "AND NOT A.cAsiDescripcion LIKE '%ELECTIVO%' AND Estado.cConDescripcion = 'Vigente' ORDER BY Cur.cCurDescripcion, PE.nCurCodigo, " & _
                            "PE.nCicCodigo, PE.nMenCodigo, PE.cCurDetCod, PE.nAsiCodigo "

        Dim MiClase As New clsManejadorDatos
        Return MiClase.objExecuteReader(SQL, MyTrans, Cn)
        MiClase = Nothing
    End Function
    Public Function Get_Academico_GruEstudio_By_Asignatura(ByVal nCurCodigo As Integer, ByVal nAsiCodigo As Integer, _
                                    ByVal nPeriodo As Integer, ByVal nCicCodigo As Integer, ByVal MyTrans As SqlTransaction, _
                                    ByVal Cn As SqlConnection, _
                                    Optional ByVal nFiltro As Integer = 0) As SqlDataReader

        Dim Filtro As String = String.Empty
        If nFiltro = 1 Then Filtro = " AND CurGrupo.nSecCodigo = 27 "

        Dim SQL As String = "SELECT CurGrupo.nCurGruCodigo, Seccion.cConDescripcion AS cSecNombre, Grupos.nGruCodigo, " & _
                            "Grupos.cGruNombre, Grupos.nTpoHora FROM (SELECT nConValor, cConDescripcion FROM Constante C " & _
                            "WHERE nConCodigo = 1093) Seccion INNER JOIN CurGrupo INNER JOIN " & _
                            "Grupos ON CurGrupo.nCurGruCodigo = Grupos.nCurGruCodigo ON Seccion.nConValor = CurGrupo.nSecCodigo " & _
                            "WHERE CurGrupo.nCurCodigo = " & nCurCodigo & " AND CurGrupo.nCicCodigo = " & nCicCodigo & " " & _
                            "AND CurGrupo.nMenCodigo = 0 AND CurGrupo.nAsiCodigo = " & nAsiCodigo & " AND " & _
                            "CurGrupo.nPrdCodigo = " & nPeriodo & " AND Grupos.nGruEstado = 1  " & Filtro & " " & _
                            "AND Grupos.nTpoHora in(1) " & _
                            "ORDER BY Seccion.cConDescripcion, Grupos.cGruNombre"

        Dim MiClase As New clsManejadorDatos
        Return MiClase.objExecuteReader(SQL, MyTrans, Cn)
        MiClase = Nothing
    End Function
    Public Function Get_Academico_GruAsignado_By_Docente(ByVal PerCodigo As String, ByVal nPeriodo As Integer, _
                                    ByVal cTipHora As Integer, ByVal cSeccion As String, _
                                    ByVal MyTrans As SqlTransaction, ByVal Cn As SqlConnection) As SqlDataReader

        Dim SQL As String = "SELECT     TOP (100) PERCENT Cur.nUniOrgCodigo, CD.nCurCodigo, Cur.cCurDescripcion, CD.cCurDetCod, " & _
                        "Asi.nAsiCodigo, Asi.cAsiDescripcion, CD.nCicCodigo, " & _
                        "Gru.cGruNombre, CG.nSecCodigo, I.cIntDescripcion, CG.nCurGruCodigo " & _
                        "FROM dbo.CurDetPersonas AS CDP INNER JOIN " & _
                        "dbo.Grupos AS Gru ON CDP.nGruCodigo = Gru.nGruCodigo INNER JOIN " & _
                        "dbo.CurGrupo AS CG ON Gru.nCurGruCodigo = CG.nCurGruCodigo INNER JOIN " & _
                        "(SELECT dbo.CurDetalle.nCurCodigo, dbo.CurDetalle.nCicCodigo, dbo.CurDetalle.nAsiCodigo, " & _
                        "ISNULL(dbo.CurDetEspecial.nMenCodigo, 0) " & _
                        "AS nMenCodigo, ISNULL(dbo.CurDetEspecial.cCurDetCod, dbo.CurDetalle.cCurDetCod) AS cCurDetCod, " & _
                        "ISNULL(dbo.CurDetEspecial.nAsiCodigoE, dbo.CurDetalle.nAsiCodigo) AS nAsiCodigoE, " & _
                        "dbo.CurDetalle.nCurDetCredito, " & _
                        "dbo.CurDetalle.nCurDetHorTeorica, dbo.CurDetalle.nCurDetHorPractica, dbo.CurDetalle.nCurDetTipo " & _
                        "FROM dbo.CurDetEspecial RIGHT OUTER JOIN " & _
                        "dbo.CurDetalle ON dbo.CurDetEspecial.nCurCodigo = dbo.CurDetalle.nCurCodigo AND " & _
                        "dbo.CurDetEspecial.nCicCodigo = dbo.CurDetalle.nCicCodigo AND dbo.CurDetEspecial.nAsiCodigo = dbo.CurDetalle.nAsiCodigo) AS CD " & _
                        "ON CG.nCurCodigo = CD.nCurCodigo AND CG.nCicCodigo = CD.nCicCodigo AND CG.nAsiCodigo = CD.nAsiCodigo AND " & _
                        "CG.nMenCodigo = CD.nMenCodigo INNER JOIN " & _
                        "dbo.Asignatura AS Asi ON CD.nAsiCodigoE = Asi.nAsiCodigo INNER JOIN " & _
                        "dbo.Curriculo AS Cur ON CD.nCurCodigo = Cur.nCurCodigo INNER JOIN " & _
                        "dbo.Interface AS I ON Cur.nUniOrgCodigo = I.nIntCodigo " & _
                        "WHERE (CDP.cPerCodigo = '" & PerCodigo & "') AND (CG.nPrdCodigo = " & nPeriodo & ") AND (I.nIntClase = 1006) " & _
                        "AND (CG.nSecCodigo in(" & cSeccion & ")) AND (Gru.nTpoHora in(" & cTipHora & ")) " & _
                        "ORDER BY Cur.nUniOrgCodigo, CD.nCurCodigo, CD.nCicCodigo, CD.cCurDetCod, Gru.cGruNombre"

        Dim MiClase As New clsManejadorDatos
        Return MiClase.objExecuteReader(SQL, MyTrans, Cn)
        MiClase = Nothing
    End Function
    Public Function Get_Academico_Archivos(ByVal cBieCodigo As String, ByVal cValor As String, ByVal MyTrans As SqlTransaction, _
                                        ByVal Cn As SqlConnection, Optional ByVal BusTipo As Integer = 0) As SqlDataReader

        Dim SQL As String = "SELECT BR.nBieRegCodigo, BR.cBieCodigo, BR.cBieRegSerie, BR.cUbiGeoCodigo AS Ubicacion, " & _
                            "MBD.nCampo, MBD.nSubCampo, MBD.cValor AS Materia, " & _
                            "MBD2.cValor AS Temas, Convert(varchar(10),BRPH.dBRPFecIni,110) AS Fecha, MBD3.cValor AS Archivo, MBD4.cValor AS RESUMEN, " & _
                            "MBD5.cValor AS REFBIBLIO, BRPH.nPerRelacion AS PerRelacion " & _
                            "FROM dbo.BienRegistro AS BR INNER JOIN " & _
                            "dbo.MatBibDescriptor AS MBD ON MBD.nBieRegCodigo = BR.nBieRegCodigo INNER JOIN " & _
                            "dbo.MatBibDescriptor AS MBD2 ON BR.nBieRegCodigo = MBD2.nBieRegCodigo INNER JOIN " & _
                            "dbo.MatBibDescriptor AS MBD3 ON BR.nBieRegCodigo = MBD3.nBieRegCodigo INNER JOIN " & _
                            "dbo.BieRegPerHisto AS BRPH ON BR.nBieRegCodigo = BRPH.nBieRegCodigo INNER JOIN " & _
                            "dbo.MatBibDescriptor AS MBD5 ON BR.nBieRegCodigo = MBD5.nBieRegCodigo INNER JOIN " & _
                            "dbo.MatBibDescriptor AS MBD4 ON BR.nBieRegCodigo = MBD4.nBieRegCodigo " & _
                            "WHERE (BR.cBieCodigo in(" & cBieCodigo & ")) AND (MBD.nCampo = 26) AND (MBD.nSubCampo = 1) " & _
                            "AND (MBD2.nCampo = 26) AND (MBD2.nSubCampo = 2) " & _
                            "AND (MBD3.nCampo = 27) AND (MBD3.nSubCampo = 1) AND (MBD5.nCampo = 27) AND " & _
                            "(MBD5.nSubCampo = 2) AND (MBD4.nCampo = 26) AND " & _
                            "(MBD4.nSubCampo = 3)"

        Dim Filtro As String = String.Empty


        Select Case BusTipo
            Case 1
                Filtro = " AND MBD.cValor Like '%" & cValor & "%'" 'Materia
            Case 2
                Filtro = " AND MBD2.cValor Like '%" & cValor & "%'" 'Temas
            Case 3
                Filtro = " AND MBD4.cValor Like '%" & cValor & "%'" 'resumen
            Case 4
                Filtro = " AND MBD5.cValor Like '%" & cValor & "%'" ' RefBibliografico
            Case 5
                Filtro = " AND (MBD.cValor Like '%" & cValor & "%' OR MBD2.cValor Like '%" & cValor & "%' OR MBD4.cValor Like '%" & cValor & "%' OR MBD5.cValor Like '%" & cValor & "%')"
        End Select

        SQL += Filtro

        Dim MiClase As New clsManejadorDatos
        Return MiClase.objExecuteReader(SQL, MyTrans, Cn)
        MiClase = Nothing
    End Function
    Public Function Get_Actividad_By_Evento(ByVal cDocCodigo As String, _
                            ByVal MyTrans As SqlTransaction, ByVal Cn As SqlConnection) As SqlDataReader

        Dim SQL As String = "SELECT DA.cDocCodigo, DA.nItem, DA.dDocActFecha, ISNULL(DA.dDocActFin, " & _
                            "DA.dDocActFecha) AS dDocActFin, DA.cDocActDescripcion, DA.nTipCodigo, " & _
                            "(DA.cDocActDescripcion + '   (' + 'Confirmaron' + '    ' + convert(varchar(4),(select Count(*) " & _
                            "FRom  RegAsistencia Where nItem =  DA.nItem AND cDocCodigo = DA.cDocCodigo)) + ')') AS Inscritos " & _
                            "FROM  DocActividad DA WHERE DA.cDocCodigo in('" & cDocCodigo & "') "

        Dim MiClase As New clsManejadorDatos
        Return MiClase.objExecuteReader(SQL, MyTrans, Cn)
        MiClase = Nothing

        '200706110814531302
    End Function
    Public Function Get_PerMisos_By_Escuela(ByVal cPerCodigo As String, ByVal MyTrans As SqlTransaction, _
                    ByVal Cn As SqlConnection) As SqlDataReader


        Using CMD As New SqlCommand("CnSeuss.spWeb_Ra", Cn)
            CMD.Parameters.Add("Opcion", Data.SqlDbType.Int)
            CMD.Parameters("Opcion").Value = 24

            CMD.Parameters.Add("cPerCodigo", Data.SqlDbType.VarChar, 10)
            CMD.Parameters("cPerCodigo").Value = cPerCodigo

            Dim CLS As New clsManejadorDatos
            Return CLS.objExecuteStoreProcedure(CMD, MyTrans, Cn)
        End Using

    End Function
    '/// OTROS USOSS
    Public Function Get_InsertAfiliacion(ByVal DNI As String, ByVal Nombre As String, ByVal Apellidos As String, _
                    ByVal Direccion As String, ByVal Distrito As String, ByVal Provincia As String, _
                    ByVal Region As String, ByVal Cn As SqlConnection)
        Dim SQL As String = "Insert Into DatPersona(DNI,NomBre,Apellidos,Direccion,Distrito,Provincia,Region) " & _
                            "Values('" & DNI & "', '" & Nombre & "','" & Apellidos & "', '" & Direccion & "', " & _
                            "'" & Distrito & "', '" & Provincia & "', '" & Region & "')"

        Dim Cmd As New SqlCommand(SQL, Cn)
        Cmd.ExecuteNonQuery()

        Cmd = Nothing

        Return 1

    End Function
    Public Function Get_SelectAfiliacion(ByVal DNI As String, ByVal Cn As SqlConnection) As SqlDataReader
        Dim SQL As String = "select * from DatPersona Where DNI = '" & DNI & "'"
        Dim CMD As New SqlCommand(SQL, Cn)
        Dim Reader As SqlDataReader
        Reader = CMD.ExecuteReader

        Return Reader

    End Function
    Public Function Get_SelectPadron(ByVal DNI As String, ByVal cRegion As String, ByVal Cn As SqlConnection) As SqlDataReader
        Dim SQL As String = "Select cPerApellido, cPerNombre, nSexo,cFecNacimiento from Per" & cRegion & " with(nolock) Where cPerIdeNumero = '" & DNI & "'"
        Dim CMD As New SqlCommand(SQL, Cn)
        Dim Reader As SqlDataReader

        CMD.CommandTimeout = 400
        Reader = CMD.ExecuteReader

        Return Reader
    End Function
    Public Function Get_SelectPerPadron(ByVal DNI As String, ByVal Cn As SqlConnection)

        Dim SQL As String = "Select cPerApellido, cPerNombre, nSexo,cFecNacimiento from PerPadron with(nolock) Where cPerIdeNumero = '" & DNI & "'"

        Dim CMD As New SqlCommand(SQL, Cn)
        Dim Reader As SqlDataReader

        Reader = CMD.ExecuteReader

        Return Reader
    End Function
    Shared Sub Ins_User_From_Login(ByRef cPerCodigo As String)
        'If cPerCodigo = String.Empty Then cPerCodigo = clsConsultasComunes.UserCode 'HttpContext.Current.Application.Get("cPerCodigo")
        Dim SQL As String = "SELECT * FROM PerUsuario WHERE cPerUsuCodigo = '" & HttpContext.Current.User.Identity.Name & "'"
        Using CMD As New SqlCommand(SQL)
            Dim clsManejador As New clsManejadorDatos
            Dim dt As New DataTable
            dt = clsManejador.Get_SP_DataTable_With_Connexion(CMD, , , CommandType.Text)
            cPerCodigo = dt.Rows.Item(0).Item(0)
        End Using
    End Sub
    Shared sPagRetunr As String
    Shared Property PageRetunr() As String
        Get
            Return sPagRetunr
        End Get
        Set(ByVal value As String)
            sPagRetunr = value
        End Set
    End Property
    Shared sUserCode As String
    Shared Property UserCode() As String
        Get
            Return sUserCode
        End Get
        Set(ByVal value As String)
            sUserCode = value
        End Set
    End Property

End Class
